import java.util.Set;
import java.util.TreeSet;

/**
 * Created with Intellij IDEA.
 * Description;
 * User:墨琦
 * Data:2023-09-25
 * Time:8:37
 */
public class Java_1 {
    /*
     * 需要满足的条件：
     * 1.不含2或者4
     * 2.三个正整数按大小排列不重复
     */
        static int fun(int n)
        {
            int m;
            while(n!=0)
            {
                m=n%10;
                if(m==2||m==4)
                    return 0;
                n=n/10;
            }
            return 1;
        }
    public static boolean flag(int i)
    {
        while(i%10!=2&&i%10!=4)
        {
            if(i<9)
            {
                return true;
            }
            i=i/10;
        }
        return false;
    }
        public static void method(int num)
        {
            int count=0;
            for(int i=1;i<2019;i++)
            {
                if(!flag(i))
                {
                    continue;
                }
                int left=i+1,right=2019-i-left;
                while(left<right)
                {
                    if(flag(left)&&flag(right))
                    {
                        count++;
                    }
                    left++;
                    right--;
                }
            }
            System.out.println(count);
        }

        public static void main(String[] args) {
            int num = 0;
            int k;
            method(2019);
            for (int i = 1; i <= 2019; i++)
            {
                for (int j = i + 1; j <= 2019; j++) {
                    k = 2019 - i - j;
                    if (k > 0 && (i != j && i != k && j != k) && (i < j && j < k)) {
                        if (fun(i) + fun(j) + fun(k) == 3)
                            num++;
                    }
                }
            System.out.println(num);
         }
        }
    }